<?php

require_once dirname(dirname(__FILE__)) . '/include/common.inc.php';
require_once dirname(dirname(__FILE__)) . '/include/econtract.class.php';
require_once INCLUDE_ROOT_PATH . 'file_server.class.php';
require_once INCLUDE_ROOT_PATH . 'econtract.class.php';
require_once dirname(dirname(__FILE__)) . '/webroot_upload/pdf.class.php';


if ($action = 'createPdf') {

    $cust_id = isset($_REQUEST['cust_id']) ? $_REQUEST['cust_id'] : 0;    //cust_id
    $rvr_id = isset($_REQUEST['rvr_id']) ? $_REQUEST['rvr_id'] : 0;    //rvr_id

    $true_name = isset($_REQUEST['true_name']) ? $_REQUEST['true_name'] : '';    //客户姓名
    $contract_num= isset($_REQUEST['contract_num']) ? $_REQUEST['contract_num'] : '';    //合同编号
    $meet_time= isset($_REQUEST['meet_time']) ? $_REQUEST['meet_time'] : '';    //时间
    $cjjl_name= isset($_REQUEST['cjjl_name']) ? $_REQUEST['cjjl_name'] : '';    //才俊/佳丽
    $emp_rname= isset($_REQUEST['emp_rname']) ? $_REQUEST['emp_rname'] : '';    //员工姓名
    $is_cjjl_true= isset($_REQUEST['is_cjjl_true']) ? $_REQUEST['is_cjjl_true'] : '';    //是否属实  属实1  不属实 2
    $not_true_reason= isset($_REQUEST['not_true_reason']) ? $_REQUEST['not_true_reason'] : '';    //理由
    $is_service_satisfied= isset($_REQUEST['is_service_satisfied']) ? $_REQUEST['is_service_satisfied'] : '';    //是否满意
    $not_satisfied_reason= isset($_REQUEST['not_satisfied_reason']) ? $_REQUEST['not_satisfied_reason'] : '';    //理由
    $time= isset($_REQUEST['time']) ? $_REQUEST['time'] : '';    //理由


    $meet_time = empty($meet_time) ? '' : date('Y-m-d H:i:s',$meet_time);

    $template = create_template($true_name,$contract_num,$meet_time,$cjjl_name,$emp_rname,$is_cjjl_true,$not_true_reason,$is_service_satisfied,$not_satisfied_reason);    //html文件

    //PDF
    $pdfs = new Pdf();
    $pdfurl = $pdfs->uploadpdf2($template, $time, "S", $cust_id, $rvr_id, 1); //type=1 电子约见确认单
    if($pdfurl){
        exit($pdfurl);
    }else{
        exit(0);
    }

}

/**
 * HTML 模板文件
 * @param $true_name
 * @param $contract_num
 * @param $meet_time
 * @param $cjjl_name
 * @param $emp_rname
 * @param $is_cjjl_true
 * @param $not_true_reason
 * @param $is_service_satisfied
 * @param $not_satisfied_reason
 * @return string
 */
function create_template($true_name,$contract_num,$meet_time,$cjjl_name,$emp_rname,$is_cjjl_true,$not_true_reason,$is_service_satisfied,$not_satisfied_reason)
{
     $html = '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>客户服务记录单</title>
    <style>
        *{ margin:0px; padding:0px; font-size:12px;}
        body{font-size:12px;}
        img,tbody,th,table,td,div,ul,li,p,span,dl,dt,dd,frame,h1,h2,h3,h4,h5{margin:0px; padding:0px; border:0px;font-size:12px;font-family:"微软雅黑"; line-height:normal; color:#000000;font-weight:normal;}
        p{ line-height:180%; vertical-align:middle; padding:5px 0px;}
        li{ list-style:none;}
        img{ border:0px;}
        a{ text-decoration:none;cursor:pointer;color:#2A95A8;cursor:pointer}
        hr{ border:0px; border-bottom:1px solid #DCDCDC; margin:3px 0px;height:1px;}
        input[type=text]{margin:0px;padding:0px;height:16px;line-height:16px;vertical-align:middle;width:200px;}
        select{width:200px;}
        inpput[type=password]{width:200px;}
        input[type=file]{border:2px solid #B2B2B2; height:20px;}
        input[type=image]{blr:expression(this.onFocus=this.blur());}
        input[type=button],input[type=submit]{*padding-top:3px;padding-left:2px;padding-right:2px;font-size:12px;line-height:12px;cursor:pointer;overflow:visible;}
        .btn_class{*padding-top:3px;padding-left:2px;padding-right:2px;font-size:12px;line-height:12px;cursor:pointer;overflow:visible;}
        input,select{vertical-align:middle;}
        input[type=checkbox]{cursor:pointer;}
        .editable {
            background: url("../../images/editable.gif") no-repeat scroll right 2px rgba(0, 0, 0, 0);
            padding-right: 20px;
            cursor: pointer;
        }

        @media print{
            .noprint {display:none}
            .paging{page-break-after :always} 
        }
        .fn-clear:after {visibility:hidden;display:block;font-size:0;content:" ";clear:both;height:0;}
        .fn-clear {zoom:1;/* for IE6 IE7 */}
        .fn-left {float:left; width:100px}
        .fn-right {float:right;}

        .bold{font-weight: bold;}
        table {border-collapse:collapse;border:solid #000;border-width:1px 0 0 1px;}
        table th, table td {border:solid #000;border-width:0 1px 1px 0;text-align: center;
        }
        .contract_con {width: 704px;/*padding: 48px 45px;*/font-family: "SimSun";font-size: 14px;margin:0 auto; position: relative;}
        .contract_con *{font-size:14px;} 
        .contract_head {border-bottom:1px solid #7a7a7a;}
        .contract_head img{margin: 10px 0 6px;width: 79.5pt;height:24pt; }
        .contract_head span{margin-top:24px;color: #000;font-size:10.5pt}
        .contract_main h2 {text-align: center; font-size: 24pt; line-height: 90px; margin-top: 40px;}
        .contract_main h4 {text-align: center; font-size: 16pt; line-height: 90px;}
        .contract_main .per span{font-weight: bold;font-size:10.5pt;margin-right: 116px;line-height: 180%;}
        .contract_main .content {font-size: 10.5pt;line-height: 22px;}
        .contract_main .content ul li{line-height: 24px;}
        .contract_main .content ul dt{font-weight: bold;}
        .contract_main .content ol li{list-style-type: decimal;margin-left: -15pt;}
        .contract_main table{margin: 0 auto 10px;}
        .contract_main .content .zero{width: 90px;}
        .contract_main .content .service_info .first{width: 165pt;}
        .contract_main .content .service_info .second,.contract_main .content .third,.contract_main .content .four,.contract_main .content .five,.contract_main .content .six,.contract_main .content .seven{width: 60pt;}
        .contract_main .content .service_info td.tl {text-align: left; line-height: 24px; padding-left: 4px;}
        .contract_main .content .service_info td.service{line-height: 32px;}
        .pt10 {padding-top: 10px;}
        .contract_main .content .tip span {text-decoration: underline; font-size: 14px;}
        .contract_main .infomation tr {line-height: 30px;}
        .contract_main .infomation td {line-height: 40px; width: 222.5pt; text-align: left; padding-left: 8pt; font-size: 12pt;}
        .contract_main .info1 td {width: 250pt; font-size: 14px; line-height: 28px;}
        .contract_main .info2 td, .contract_main .info2 th {line-height: 22px;}
        .contract_main .info2 td {width: 265pt;}
        .contract_main .info2 td.num {text-align: center; width: 185pt;}
        .contract_main tr{height: 26px;}
        .promise p {text-indent: 24pt; font-size: 12pt; line-height: 32pt;}
        .contract_main .fujian {font-size: 12pt; line-height: 32pt;}
        .disclaimer{line-height: 26px;}
        .location{position: relative; width: 100%; height: 270px;}
        .location table {width: 96%;}
        .seal{position: absolute;right:80px;top: 0px;width: 170px;height: 170px;overflow: hidden;z-index: -10}
        .seal img{width: 127.5pt;height: 127.5pt;}
        span.block_button {background: url(../images/button09.gif) repeat-x;height: 14px;border: 1px solid #51a2cc;padding: 5px 8px;color: #2991c7; font-family: "SimSun";margin: 2px;cursor: pointer;display: inline-block;}
        .add_record{background-color:silver;height: 14px;border: 1px solid gray;padding: 5px 8px;color: black;font-family: "SimSun";margin: 2px;cursor: crosshair;display: inline-block;}

        .contract_main ul.basic {width: 400px; margin: 400px auto 100px;}
        .contract_main ul.basic li {font-size: 15pt; height: 60px;}
        .contract_main ul.basic li span, .contract_main ul.basic li div {font-size: 15pt;}
        .contract_main em {display: inline-block; width: 12px; height: 12px; border: 1px solid #7a7a7a; vertical-align: middle; margin: 0 20px 0 5px; position: relative;}
        .contract_main em i {position: absolute; left: 0; bottom: 15px; width: 12px; height: 12px;}
        .contract_main .service_info ul.tip li { list-style-type: decimal;  margin-left: 15pt;}
        .contract_main .id_card_pic {width: 100%; height: auto;}
        .contract_main .id_card_pic img {max-width: 100%; height:200px;}
        .contract_main td.m_title {text-align: center;}
        .basic_info .fn-left, .basic_info .fn-right {width: 50%; text-align: left; display: inline-block;}
        .contract_main .box {border: 1px solid #7a7a7a; width: 96%; height: 110px; font-size: 12px!important; line-height: 14px!important;}
        .contract_main .content strong {font-size: 15px;}
        .basic_info .content em {margin: 0 5px 0 20px;}
        .basic_info .content em i {bottom: 7px;}
        .basic_info .content div.code {display: inline-block;}
        .basic_info .content div.code span {display: inline-block; border: 1px solid #7a7a7a; border-left: none; width: 20px; line-height: 30px; text-align: center; text-decoration: none;}
        .basic_info .content div.code span.one {border-left: 1px solid #7a7a7a;}
        .basic_info .content p {line-height: 180%; vertical-align: middle; padding: 5px 0;}
        .basic_info .box {line-height: 180%; vertical-align: middle; padding: 5px;}
        .basic_info .content ul.basic_info_ul li {padding: 3px 0;}
        .basic_info .content ul.basic_info_ul li div {line-height: 26px;}
        .emlist div {display: inline-block;}
        .emlist div em i {bottom: 8px;}
        .p10 {padding: 10px 0;}
        .mb10 {margin-bottom: 10px;}  

        /* 鐩磋惀 */
        .contract_main .content p, .contract_main .content table td, .contract_main .content table th, .contract_main .content li, .contract_main .content div {font-size: 13px;}
        .contract_main .content .service_info li, .contract_main .content .service_info ul li {font-size: 16px; line-height: 32px; margin-bottom: 10px;}
        .contract_main .txt p {font-size: 16px; line-height: 28px;}

        .contract_main .content .ht-title { font-size: 22px; line-height: 30px; text-align: center; font-weight: bold; }
        .contract_main .content .ht-sub-title { font-size: 20px; line-height: 24px; text-align: center; }
    </style>
</head>
<body>
    <div class="contract_con">
        <div class="contract_main">
            <div class="content" style="padding-top:40px;">
                <p class="ht-title">客户服务记录单</p>
                <div class="fn-clear" style="padding-top:40px;">
                    <div class="fn-left" style="width:50%;">
                        <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">客户姓名</i>：';


    $html .= $true_name;

    $html .= '
                        </p>
                    </div>
                    <div class="fn-right" style="width:50%;">
                        <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">合同编号</i>：
                        ';
    $html .= $contract_num;
    $html .=   '</p>
                    </div>
                </div>
                <div>
                    <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">时间</i>：
                    ';

    $html .= $meet_time;
                   $html .= ' </p>
                </div>
                <div>
                    <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">才俊/佳丽</i>：
                    ';

    $html .= $cjjl_name;
                   $html .= '</p>
                </div>
                <div>
                    <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">服务红娘</i>：
                    ';
    $html .= $emp_rname;
    $html .=  '</p>
                </div>
                <div>
                    <p style="font-size:16px;">今天约见的才俊/佳丽的情况是否属实。</p>
                </div>
                <div class="fn-clear">
                ';

    if($is_cjjl_true == 1){
        $html .=  '<div class="fn-left" style="width:15%;">
                       <p style="font-size:16px;"><em><i style=\'top:-7px;\'>&radic;</i></em>属实；</p>
                    </div>
                    <div class="fn-right" style="width:85%;">
                        <p style="font-size:16px;"><em>&nbsp;&nbsp;</em>不属实，理由：</p>
                    </div>
                    ';
    }else{

        $html .=   '
                    <div class="fn-left" style="width:15%;">
                       <p style="font-size:16px;"><em>&nbsp;&nbsp;</em>属实；</p>
                    </div>
                    <div class="fn-right" style="width:85%;">
                        <p style="font-size:16px;"><em><i style=\'top:-7px;\'>&radic;</i></em>不属实，理由：
                        ';
        $html .= $not_true_reason;
        $html .= '</p>
                    </div>';
    }




    $html .= '</div>
                <div>
                    <p style="font-size:16px;">您对红娘今天提供的服务是否满意。</p>
                </div>
                <div class="fn-clear">';
                
                
    if($is_service_satisfied == 1){
        $html .=  ' <div class="fn-left" style="width:15%;">
                        <p style="font-size:16px;"><em><i style=\'top:-7px;\'>&radic;</i></em>满意；</p>
                    </div>
                    <div class="fn-right" style="width:85%;">
                        <p style="font-size:16px;"><em>&nbsp;&nbsp;</em>不满意。</p>
                    </div>';
    }else{
        $html .=  ' <div class="fn-left" style="width:15%;">
                        <p style="font-size:16px;"><em>&nbsp;&nbsp;</em>满意；</p>
                    </div>
                    <div class="fn-right" style="width:85%;">
                        <p style="font-size:16px;"><em><i style=\'top:-7px;\'>&radic;</i></em>不满意，理由：
                        ';

        $html .= $not_satisfied_reason;
        $html .=  '</p>
                    </div>';
    }
                    

                
                
                
                
                
                $html .= '</div>
                <div class="fn-clear">
                    <div class="fn-right" style="width:50%;">
                        <p style="font-size:16px;"><i style="font-style: normal;font-size: 16px;">客户签字</i>：
                        ';

    $html .= '</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
';


    return $html;
}





